package com.szxw.controller;

import com.szxw.pojo.User;
import com.szxw.service.impl.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: 苏执小威
 * @Email:1410511702@qq.com
 * @Desc:
 * @Date: 2022/5/18 10:44
 */
@Controller
public class UserController {
    @Autowired
    @Qualifier("UserServiceImpl")
    private UserServiceImpl service;
    
    @RequestMapping("/toLogin")
    public String toLogin(){
        return "login";
    }
    @RequestMapping("/login")
    public String login(Model model, String email, String pswd){
        Map<Object, Object> map = new HashMap<>();
        map.put("email",email);
        map.put("pswd",pswd);
        User user = service.loginBlog(map);
        model.addAttribute("user",user);
        return "dashboard";
    }
    
}
